#include <stdlib.h>
#include <clutter/clutter.h>


int main(int argc , char * argv[])
{
    /* 对于第四个参数：alpha参数的试验：这是透明度。源色彩是指，正要被写到帧缓冲区的那个像素，
     * 目标色彩是指已经存在于帧缓冲区的那个像素，在当前设置下，最终的色彩 = 源色彩 * ALPHA + 
     * 目标色彩 * 1。这里的ALPAH＝alpha/ff。 由于我们的背景设置为0，即实际的RBG是前面给出的
     * 数值*alpha/ff
     */ 
    ClutterColor stage_color ={0x00,0x00,0x00,0xff};
    ClutterColor actor_color ={0xff,0xff,0xff,0xB0};

    if ( clutter_init(&argc, & argv) < 0 )
    {
        perror("clutter_init err:");
        exit(-1);
    }

    ClutterActor *stage = clutter_stage_new();
    clutter_actor_set_size(stage,400,300);
    clutter_actor_set_background_color(stage,&stage_color);
    /* quit on destroy */
    g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);


    /*在stage中添加一个rect（方形）图案，学习ClutterRectangle。*/ 
    ClutterActor * rect = clutter_actor_new ();
    clutter_actor_set_background_color(rect,&actor_color);
    clutter_actor_set_size(rect,100,100);
    clutter_actor_add_child(stage, rect);
    clutter_actor_set_position(rect,20,20);

    /*在stage中加入一个label，学习Cluttertext，分别试验英文和中文两种显示 */ 
    ClutterActor * label1 = clutter_text_new_full ("Sans 10", "Hello,world", &actor_color); 
    ClutterActor * label2 = clutter_text_new_full ("微软雅黑 14", "你好", &actor_color);
    clutter_actor_set_position(label1, 20, 140);
    clutter_actor_set_position(label2, 20, 200);
    clutter_actor_add_child ( stage, label1);
    clutter_actor_add_child ( stage, label2);
    
    clutter_actor_show(stage);

    clutter_main();

    return EXIT_SUCCESS;
}